<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>document改元素</title>
		<script>
			function changePos(){
				var h=document.getElementById("d");
				console.log(typeof(h));
				if(d.align=="right")
				   d.align="left";
				else   
				   d.align="right";
				   
				d.innerHTML="这部电影其实一般！";   
			}
			function buyTicket(){
				// document.getElementById("d").innerHTML="<a href='https://www.taobao.com' target='_blank'>猫眼电影</a>";
				document.getElementById("d").innerText="<a href='https://www.taobao.com' target='_blank'>猫眼电影</a>";
			}
			function changeImg(){
				let im=document.getElementsByTagName("img")[0];
				im.src="../images/lovk.jpg";
			}
			
			function getLike(){
				//document.getElementsByTagName("input");
				// o.name="like"
				var n=document.getElementsByName("like");
				let str="";
				for(let o of n){
					if(o.checked){
						str+=o.value+"&nbsp;&nbsp;";
					}
				}
				document.getElementById("youlike").innerHTML=str;
			}
		</script>
	</head>
	<body>
		<h2 id="d">阿凡达2-水世界</h2>
		<div>
			<img src="../images/kongzi.jpg" />
		</div>
		<div>
			爱好:
			<input type="checkbox" name="like" value="singing" />唱歌
			<input type="checkbox" name="like" value="dancing" />跳舞
			<input type="checkbox" name="like" value="rap" />说唱
			<input type="checkbox" name="like" checked value="篮球" />篮球
			<input type="checkbox" name="like" value="打游戏" />打游戏
			
		</div>
		<div>
			<button type="button" onclick="changePos()">改元素</button>
			<button type="button" onclick="buyTicket()">生成买票链接</button> 
			<button type="button" onclick="changeImg()">换一张图</button>
			<button type="button" onclick="getLike()">你喜欢什么</button>
		</div>
		<p id="youlike" style="font-size: 90px;color:red;"></p>
	</body>
</html>